#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <string.h>
int arr[10000] = { 0 };
void yzc(int* p, int n, int m)
{
	int arr1[100] = { 0 };
	int arr2[100] = { 0 };
	memcpy(arr1, p, 4 * (n - m));
	memcpy(arr2, p + n - m, 4 * m);
	for (int i = 0; i < m; i++)
	{
		p[i] = arr2[i];
	}
	for (int q = 0; q < n - m; q++)
	{
		p[m+q] = arr1[q];
	}
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	int m;
	scanf("%d", &m);
	int* p = arr;
	yzc(p, n, m);
	for (int i = 0; i < n; i++)
	{
		printf("%d ", p[i]);
	}
	return 0;
}